package gocode

import (
	"encoding/json"
	"io"
)

type Candidate struct {
	Class   string `json:"class"`
	PkgPath string `json:"package"`
	Name    string `json:"name"`
	Type    string `json:"type"`
}

func jsonFormat(w io.Writer, candidates []Candidate, num int) error {
	var result []interface{}
	if candidates != nil {
		result = []interface{}{num, candidates}
	}
	err := json.NewEncoder(w).Encode(result)
	return err
}
